package me.zhanshi123.lab4.controller;

import me.zhanshi123.lab4.service.ICategoryService;
import me.zhanshi123.lab4.service.impl.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/category")
public class CategoryController {
    @Autowired
    private ICategoryService categoryService;

    @RequestMapping("/list")
    public String listAll() {
        return categoryService.listAll();
    }

    @RequestMapping("/add")
    public String add(@RequestParam("name") String name) {
        return categoryService.add(name);
    }
}
